package com.lsl.test1;

import com.lsl.test.Person;
import org.junit.Test;

import java.lang.reflect.Field;

/**
 * @author lishuailong
 * @create 2020-07-16 16:57
 */
public class FieldTest {
    @Test
    public void test(){
        Class<Person> aClass = Person.class;

        //获取属性
        Field[] fields = aClass.getDeclaredFields();
        for (Field field : fields) {
            System.out.println("field = " + field);
        }
    }
    @Test
    public void test1(){
        Class<Person> aClass = Person.class;

        //获取属性
        Field[] fields = aClass.getDeclaredFields();
        for (Field field : fields) {
            //权限修饰符
            System.out.println("field = " + field.getModifiers());
            //数据类型
            System.out.println("field = " + field.getType());
        }
    }
}
